//
//  DiscoverSearchView.swift
//  swiftImitationWeibo
//
//  Created by 杨果果 on 16/7/12.
//  Copyright © 2016年 yang. All rights reserved.
//

import UIKit

class DiscoverSearchView: UIView,UITextFieldDelegate {

    @IBOutlet weak var searchTextfield: UITextField!
   
    
    @IBOutlet weak var cencleBtn: UIButton!
    @IBOutlet weak var searchTextFieldright: NSLayoutConstraint!
    
    @IBAction func cencleButton(sender: AnyObject) {
        //取消第一响应
        searchTextfield.resignFirstResponder()
        searchTextFieldright.constant = 0
        UIView.animateWithDuration(0.25) { () -> Void in
            self.layoutIfNeeded()
        }
        
        
        
    }
    
    
    class func serachView() -> DiscoverSearchView {
        return UINib(nibName: "DiscoverSerachView", bundle: nil).instantiateWithOwner(nil, options: nil).last! as! DiscoverSearchView
    }
    
    
// MARK:  --   textfield 代理方法
    func textFieldDidBeginEditing(textField: UITextField) {
        searchTextFieldright.constant = cencleBtn.width
        UIView.animateWithDuration(0.25) { () -> Void in
            self.layoutIfNeeded()
        }
    }
    
    
    
    

}
